var localMedia = document.querySelector('#localMedia');
var remoteVideo = document.querySelector('#remoteVideo');


navigator.getUserMedia({
    vedio: true,
    audio: true
},function (mediaStream){
    console.log('getUserMedia success');

    //创建与服务端连接
    var pc = new RTCPeerConnection(null);
    //连接添加音视频流
    mediaStream.getTracks().forEach(track => { pc.addTrack(track, localStream); });

    pc.createOffer().then(offer => {
        //设置本地sdp
        return pc.setLocalDescription(offer);
    }).then( () =>{
        //发送给服务器
        sendToServer({
            name: myUsername,
            target: targetUsername,
            type: "video-offer",
            sdp: pc.localDescription
        });
    }).catch(function(reason) {
        // An error occurred, so handle the failure to connect
    });
});